package cn.xchats.rpc.client.load;

/*
 *轮询策略
 *@author teddy
 *@date 2018/7/10
 */
public class RoundrobinLoadBalance extends LoadBalanceConfig {

    private static int selectIndex = 0;

    private static final int threshold = serverAddressList.size() - 1;

    @Override
    public int select() {
        synchronized (RoundrobinLoadBalance.class) {
            if (selectIndex == threshold)
                selectIndex = 0;
            else
                ++selectIndex;
        }
        return selectIndex;
    }


}
